The top-seeded Serb, who had not dropped a set in four matches since the round of 16 at the Australian Open in January, looked out-of-sorts throughout the 98-minute contest.
Under the lights on the stadium court, Williams smashed 39 winners to defeat Azarenka 7-5, 6-3 in a rematch of the 2016 final, which the Belarusian won.
Daniil Medvedev and Karen Khachanov crushed second seed Dominic Thiem and third seed Alexander Zverev respectively to set up an all-Russian semi-final at the Rogers Cup in Montreal on Friday.
World number five Alexander Zverev continued his poor recent form as he crashed out of the Italian Open in the second round while Serena Williams had to pull out of the women's draw with a recurring knee injury.
Images from Day 7 of the 2019 French Open in Paris on Saturday.
Images from Day 1 of the 2020 French Open, in Paris, on Sunday.
Federer, who skipped the entire clay court season after winning the Australian Open and claiming titles at Indian Wells and Miami this year, will next play defending champion Florian Mayer who beat Frenchman Lucas Pouille in three sets.
A summary of Day Three's matches at the Wimbledon Championships.
Top 10 seeds David Ferrer, Tomas Berdych, Stan Wawrinka and Richard Gasquet raced into the second round of the Australian Open on Monday, apparently eager to make the most of relatively mild conditions at Melbourne Park.
The seventh-seeded Bulgarian advanced to his eighth ATP World Tour Masters 1000 quarter-final with a 6-3, 7-5 victory over Del Potro, who struggled with the intense heat in the closing stages of the one hour, 39 minute match.
The lanky wild card kissed the Montreal court after completing a rousing 3-6, 6-4, 7-6(4) triumph as the 18-year-old became the youngest player to ever reach the quarter-finals of an ATP Masters 1000 event.
IMAGES from Day 6 at Wimbledon on Saturday.
India's Leander Paes and his German partner Alexander Zverev went down to the Spanish duo of Feliciano Lopez and Marc Lopez in a men's doubles first round match to bow out of the Cincinnati Open.
Images from Day 1 of the Wimbledon Championships.